package cn.test.demo.base_demo.security;

/**
 * @author 王杨帅
 * @create 2018-04-29 17:15
 * @desc 模拟用户登录，该类可以设定用户和获取用户
 **/
public class CurrentSetHolder {
    private final static ThreadLocal<String> holder = new ThreadLocal<>();

    /**
     * 获取用户
     * @return
     */
    public static String get() {
        return holder.get() == null ? "unknown" : holder.get();
    }

    /**
     * 设定用户
     * @param user
     */
    public static void set(String user) {
        holder.set(user);
    }
}

